7273a67f81b2f76c897888f456615d76f777716e,workbench/mps-editor/source_gen/jetbrains/mps/ide/editor/actions/AddModelImportByRoot_Action.java,AddModelImportByRoot_Action,doExecute,#AnActionEvent#Map#,88

Before Change


      if (isEmptyString(initialText.value)) {

        if (errorLabel != null) {
          initialText.value = errorLabel.getRenderedText();
        } else if (unresolvedReference != null) {
          initialText.value = SPropertyOperations.getString(unresolvedReference, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x28e9fc3ba3fa3940L, 0x28e9fc3ba3fa3941L, "resolveName"));
        }
      }

      ImportHelper.addModelImportByRoot(((Project) MapSequence.fromMap(_params).get("project")), ((SModule) MapSequence.fromMap(_params).get("module")), ((SModel) MapSequence.fromMap(_params).get("model")), initialText.value, AddModelImportByRoot_Action.this, new ImportHelper.ModelImportByRootCallback() {
        public void importForRootAdded(String rootName) {
          String textToMatch = (rootName != null ? rootName : initialText.value);
          if (textToMatch.length() == 0) {
            return;
          }
          SubstituteInfo substituteInfo = null;
          if (errorLabel != null) {
            substituteInfo = errorLabel.getSubstituteInfo();
          } else if (unresolvedReference != null && ((EditorContext) MapSequence.fromMap(_params).get("editorContext")) != null) {
            substituteInfo = new DefaultChildSubstituteInfo(SNodeOperations.getParent(unresolvedReference), unresolvedReference, SNodeOperations.getContainingLinkDeclaration(unresolvedReference), ((EditorContext) MapSequence.fromMap(_params).get("editorContext")));
            substituteInfo.setOriginalText(initialText.value);
          }
          if (substituteInfo == null) {
            return;
          }
          substituteInfo.invalidateActions();
          List<SubstituteAction> matchingActions = substituteInfo.getMatchingActions(textToMatch, true);
          if (ListSequence.fromList(matchingActions).count() == 1) {
            ListSequence.fromList(matchingActions).first().substitute(((EditorContext) MapSequence.fromMap(_params).get("editorContext")), initialText.value);
          }
        }
      });
    } catch (Throwable t) {
      if (LOG.isEnabledFor(Level.ERROR)) {
        LOG.error("User's action execute method failed. Action:" + "AddModelImportByRoot", t);

After Change


      final Wrappers._T<String> initialText = new Wrappers._T<String>("");

      final Wrappers._T<EditorCell_Label> errorLabel = new Wrappers._T<EditorCell_Label>(null);
      final Wrappers._T<SNode> unresolvedReference = new Wrappers._T<SNode>(null);
      if (((EditorComponent) MapSequence.fromMap(_params).get("editorComponent")) != null) {
        unresolvedReference.value = SNodeOperations.as(((SNode) MapSequence.fromMap(_params).get("node")), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x28e9fc3ba3fa3940L, "jetbrains.mps.baseLanguage.structure.UnresolvedNameReference"));
        errorLabel.value = AddModelImportByRoot_Action.this.getErrorCell(_params);
        NodeSubstituteChooser nodeSubstituteChooser = ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent")).getNodeSubstituteChooser();
        if (check_a68f4j_a3a4a0(nodeSubstituteChooser)) {
          String pattern = nodeSubstituteChooser.getPatternEditor().getPattern();
          if (check_a68f4j_a1a3a4a0(pattern)) {
            initialText.value = pattern;
          }
        }
        if (isEmptyString(initialText.value)) {
          EditorCell_Label label = AddModelImportByRoot_Action.this.getCellLabel(_params);
          String selectedText = check_a68f4j_a0b0e0e0a(label);
          if (selectedText != null && !(selectedText.isEmpty())) {
            initialText.value = selectedText;
          }
        }

        if (isEmptyString(initialText.value)) {

          if (errorLabel.value != null) {
            initialText.value = errorLabel.value.getRenderedText();
          } else if (unresolvedReference.value != null) {
            initialText.value = SPropertyOperations.getString(unresolvedReference.value, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x28e9fc3ba3fa3940L, 0x28e9fc3ba3fa3941L, "resolveName"));
          }
        }

      }
      ImportHelper.addModelImportByRoot(((Project) MapSequence.fromMap(_params).get("project")), ((SModule) MapSequence.fromMap(_params).get("module")), ((SModel) MapSequence.fromMap(_params).get("model")), initialText.value, AddModelImportByRoot_Action.this, new ImportHelper.ModelImportByRootCallback() {
        public void importForRootAdded(String rootName) {
          String textToMatch = (rootName != null ? rootName : initialText.value);
          if (textToMatch.length() == 0) {
            return;
          }
          SubstituteInfo substituteInfo = null;
          if (errorLabel.value != null) {
            substituteInfo = errorLabel.value.getSubstituteInfo();
          } else if (unresolvedReference.value != null && ((EditorContext) MapSequence.fromMap(_params).get("editorContext")) != null) {
            substituteInfo = new DefaultChildSubstituteInfo(SNodeOperations.getParent(unresolvedReference.value), unresolvedReference.value, SNodeOperations.getContainingLinkDeclaration(unresolvedReference.value), ((EditorContext) MapSequence.fromMap(_params).get("editorContext")));
            substituteInfo.setOriginalText(initialText.value);
          }
          if (substituteInfo == null) {
            return;
          }
          substituteInfo.invalidateActions();
          List<SubstituteAction> matchingActions = substituteInfo.getMatchingActions(textToMatch, true);
          if (ListSequence.fromList(matchingActions).count() == 1) {
            ListSequence.fromList(matchingActions).first().substitute(((EditorContext) MapSequence.fromMap(_params).get("editorContext")), initialText.value);
          }
        }
      });
    } catch (Throwable t) {
      if (LOG.isEnabledFor(Level.ERROR)) {
        LOG.error("User's action execute method failed. Action:" + "AddModelImportByRoot", t);